#ifndef CPMAGNETICFIELD_H
#define CPMAGNETICFIELD_H

#include <TObject.h>
#include <TMath.h>
#include <TF1.h>
#include <CpMagneticParticle.h>

class CpMagneticField : public TObject {
public:
   enum EType {
      kDefault = 0,
      kLastType
   };

   enum EMagneticField {
      kAnalytic = 0,
      kMap,
      kLastMagneticField
   };

   enum EMapType {
      kMapOneType = 0,
      kLastMapType
   };

   CpMagneticField();
   ~CpMagneticField();

   void      Print();

   inline Double_t Mi_0() { return 4 * TMath::Pi() * 1e-7; }
   inline Double_t M_p() { return 450000; }

   Double_t  GradientOfMagneticField(EMagneticField type, Double_t value);
   Double_t  GradientOfMagneticFieldAnalytic(Double_t value);
   Double_t  GradientOfMagneticFieldFromMap(EMapType type);
   Double_t  ValueAtAnalyticFunction(Double_t value);
   Double_t  Force(Double_t value = 1.0);

   void      SetMapType(EMapType type) { fMapType = type; }
   void      SetMagneticFieldType(EMagneticField type) { fMagneticFieldType = type; }

   void      SetAnalyticFunction(TString functionString, Double_t min, Double_t max);

private:

   CpMagneticParticle  fMagneticParticle;

   EMagneticField      fMagneticFieldType;
   EMapType            fMapType;

   TF1                 *fAnalyticFunction;

   ClassDef(CpMagneticField, 1);
};

#endif
